home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************
- * *
- * (C) Copyright 2002 - 2004, Human Concepts (tm) *
- * *
- ***********************************************************
- * File name: chartFunc.js *
- * Author: Andrey Ponomarev *
- **********************************************************/
-
- window.onresize = onChartPageResized
- window.onscroll = onChartPageScrolled
-
- var strActiveBoxId = "";
- var strActiveSubBoxId = "";
- var objBoxMouseOver;
- var timerId = -1;
- var HotspotProfilesTimerId = -1;
- var nTimerCount = 0;
-
- function onBoxMouseMove()
- {
- nTimerCount = 0;
- var objGroup = GetGroupForObject(event.srcElement)
- if ( typeof(objBoxMouseOver) == 'undefined' ||
- objBoxMouseOver.id != objGroup.id ||
- strActiveBoxId != objBoxMouseOver.id && timerId <= 0 )
- {
- objBoxMouseOver = objGroup;
-
- if (timerId > 0)
- window.clearInterval(timerId);
-
- timerId = window.setInterval("onTimerFunc()", 2000);
- }
- }
-
- function onBoxMouseOut()
- {
- if (timerId != -1)
- {
- var objGroup = GetGroupForObject(event.fromElement)
- var objTo = GetGroupForObject(event.toElement)
- if ( typeof(objTo) == 'undefined' || objTo == null || objGroup != objTo)
- {
- window.clearInterval(timerId)
- timerId = -1
- }
- }
- }
-
- function onTimerFunc()
- {
- nTimerCount++
- if (nTimerCount == 4)
- {
- window.clearInterval(timerId)
- timerId = -1
- onClickGroupObj(objBoxMouseOver)
- }
- }
-
- function onClickGroup()
- {
- onClickGroupObj(event.srcElement);
- }
-
- function onClickSubBox()
- {
- onClickSubBoxObj( event.srcElement );
- };
-
- function onClickGroupObj(obj)
- {
- if (typeof(obj) != "object")
- return;
-
- var objGroup = GetGroupForObject(obj);
- onSelectChartBox(objGroup);
- }
-
- function onClickSubBoxObj( obj )
- {
- if (typeof(obj) != "object")
- return;
-
- var oParentGroup = GetGroupForObject( obj );
- if( strActiveBoxId != oParentGroup.id )
- {
- onSelectChartBox( oParentGroup );
- return;
- }
-
- var objGroup = GetBoxForObject(obj);
- onSelectSubBox(objGroup);
- };
-
- function GetGroupForObject(obj)
- {
- var objGroup = obj;
- if ( obj != null && typeof(obj) != 'undefined' )
- {
- if (objGroup.nodeName == "textbox")
- objGroup = objGroup.parentElement;
-
- if (objGroup.nodeName != "group")
- {
- var parent = objGroup.parentElement;
- if(parent.nodeName == "A") //drill
- return parent.parentElement;
- return parent;
- }
- }
- return objGroup;
- }
-
- function GetBoxForObject( obj )
- {
- var objGroup = obj
- if ( obj != null && typeof(obj) != 'undefined' )
- {
- while( typeof(objGroup) != 'undefined' && objGroup != null )
- {
- if( typeof(objGroup.selectable) != 'undefined' && objGroup.selectable == "true" &&
- typeof(objGroup.id) != 'undefined' && objGroup.id != "" )
- {
- return objGroup;
- };
-
- objGroup = objGroup.parentElement;
- };
- }
- return objGroup
- };
-
- function onClickPage()
- {
- clearBoxHighlighting();
- clearSubBoxHighlighting();
- strActiveBoxId = "";
- strActiveSubBoxId = "";
-
- var obj = parent.hcNavigate;
- if ( typeof( obj ) == "object" && typeof( obj.clearPage ) != "undefined" )
- obj.clearPage()
- }
-
- function onMouseWheeling()
- {
- //mouse wheel works only for IE 6
- var obj = parent.hcToolbar
- if( typeof(obj) == "object" && typeof( obj.onChartMouseWheeling ) != "undefined" )
- {
- obj.onChartMouseWheeling(event)
- }
- }
-
- function onChartPageInit()
- {
- if (getIEVersion() < 5.0)
- {
- document.body.innerText = "";
- alert("You have an old version of Internet Explorer" + //Loc
- " - Update it please at least to Version 5.0.\nTo have a full functionality " +
- "you should install Version 5.5, 6.0 or higher.");
- }
- else
- {
- var oGroup
- var strHash = window.location.hash
- if ( strHash != "" )
- {
- var strId = strHash.substring( 1, strHash.length )
- oGroup = getGroupBoxById(strId)
- }
- else
- {
- oGroup = findFirstGroupBox()
- }
-
- if ( typeof(oGroup) == "object" && oGroup != null)
- {
- if ( typeof(parent.hcNavigate) == "object" && typeof (parent.hcNavigate.fillPage) != "undefined" )
- {
- parent.hcNavigate.fillPage(oGroup)
- }
-
- clearBoxHighlighting()
- strActiveBoxId = oGroup.id
-
- if ( strHash != "" )
- {
- highlightSelectedBox()
- navigateDeffered()
- }
- }
- else
- {
- strActiveBoxId = "";
- strActiveSubBoxId = "";
- }
-
- initOverviewWindow()
- updateOverviewWindow()
-
- var obj = parent.hcToolbar
- if( typeof(obj) == "object" && typeof( obj.setZoom ) != "undefined" )
- {
- obj.ZoomToFitInit()
- }
- }
- }
-
- function onChartPageScrolled()
- {
- updateOverviewWindow()
- }
-
- function getProfilesObj()
- {
- if( parent.hcPersons == null )
- return;
- var spanObjs = parent.hcPersons.document.body.children.tags("span")
- if(spanObjs.length == 0)
- return null
- var idxObj = null
- for(var j = 0; j < spanObjs.length; ++j)
- {
- if(spanObjs(j).id == "Index")
- {
- idxObj = spanObjs(j)
- break
- }
- }
- spanObjs = idxObj.children.tags("span");
- if(spanObjs.length == 0)
- return;
- var personsObj = null;
- for(var j = 0; j < spanObjs.length; ++j)
- {
- if(spanObjs(j).id == "ProfileInfo")
- {
- personsObj = spanObjs(j) ;
- break;
- }
- }
- return personsObj;
- }
-
- function getDirictoresObj()
- {
- if( parent.hcPersons == null )
- return;
- var spanObjs = parent.hcPersons.document.body.children.tags("span")
- if(spanObjs.length == 0)
- return null
- var idxObj = null
- for(var j = 0; j < spanObjs.length; ++j)
- {
- if(spanObjs(j).id == "Index")
- {
- idxObj = spanObjs(j)
- break
- }
- }
- spanObjs = idxObj.children.tags("span");
- if(spanObjs.length == 0)
- return;
- var personsObj = null;
- for(var j = 0; j < spanObjs.length; ++j)
- {
- if(spanObjs(j).id == "DirInfo")
- {
- personsObj = spanObjs(j) ;
- break;
- }
- }
- return personsObj;
- }
-
- function updateOverviewWindow()
- {
- var obj = parent.hcToolbar;
- if( typeof(obj) == "object" && typeof( obj.updateOverviewWindow ) != "undefined" )
- {
- obj.updateOverviewWindow();
- }
- }
-
- function initOverviewWindow()
- {
- var obj = parent.hcToolbar;
- if( typeof(obj) == "object" && typeof( obj.initOverviewWindow ) != "undefined" )
- {
- obj.initOverviewWindow();
- }
- }
-
- function findFirstGroupBox()
- {
- var groupObjs = document.getElementsByTagName("group");
- if (groupObjs.length > 0)
- return groupObjs(1);
-
- return null;
- }
-
- function FillPanel( p_oGroupObj )
- {
- var obj = parent.hcNavigate;
- if ( typeof( obj ) == "object" && typeof( obj.fillPage ) != "undefined" )
- obj.fillPage(p_oGroupObj);
- };
-
- function onSelectChartBox(groupObj)
- {
- clearBoxHighlighting();
- if(groupObj.id == "PageGroup")
- {
- strActiveBoxId = "";
- return;
- };
-
- if( groupObj.id != strActiveBoxId )
- clearSubBoxHighlighting();
-
- strActiveBoxId = groupObj.id;
- highlightSelectedBox();
-
- FillPanel( groupObj );
- }
-
- function onSelectSubBox( p_oGroupObj )
- {
- clearSubBoxHighlighting();
- strActiveSubBoxId = p_oGroupObj.id;
- highlightSelectedSubBox();
-
- FillPanel( p_oGroupObj );
- };
-
- function getSubBoxById( strId )
- {
- if ( strId == "" ) return;
-
- var groupObjs = document.getElementsByTagName("rect")
- for (i = 0; i < groupObjs.length; i++)
- {
- if (groupObjs(i).id == strId)
- {
- return groupObjs(i)
- }
- }
-
- return null;
- };
-
- function getGroupBoxById(strId)
- {
- if ( strId == "" ) return;
- var groupObjs = document.getElementsByTagName("group")
- for (i = 0; i < groupObjs.length; i++)
- {
- if (groupObjs(i).id == strId)
- {
- return groupObjs(i)
- }
- }
-
- groupObjs = document.getElementsByTagName("rect")
- for (i = 0; i < groupObjs.length; i++)
- {
- if (groupObjs(i).id == strId)
- {
- return groupObjs(i)
- }
- }
-
- return null;
- }
-
- function navigateBox(strId)
- {
- var obj = getGroupBoxById(strId)
- if (typeof(obj) == "object")
- {
- onSelectChartBox(obj)
- }
-
- var toolBar = parent.hcToolbar;
- if( toolBar == null ) return;
- toolBar.tryCenterPage();
- }
-
- var timerNavigateId = -1
- function navigateDeffered()
- {
- if(timerNavigateId == -1)
- {
- timerNavigateId = window.setInterval("onTimerNavigateFunc()", 150)
- }
- }
-
- function onTimerNavigateFunc()
- {
- window.clearInterval(timerNavigateId);
- timerNavigateId = -1;
- navigateBox(strActiveBoxId);
- }
-
- function onNavigatePageInit()
- {
- var obj = getGroupBoxById(strActiveBoxId);
- FillPanel(obj);
- }
-
- function highlightSelectedBox()
- {
- var obj = getGroupBoxById(strActiveBoxId);
- setOpacityForGroupBox(obj, 0.4);
- }
-
- function highlightSelectedSubBox()
- {
- if( strActiveSubBoxId )
- {
- var obj = getSubBoxById(strActiveSubBoxId);
- obj.style.backgroundColor = "#AFFFAF";
- };
- };
-
- function clearBoxHighlighting()
- {
- if (strActiveBoxId != "")
- {
- var obj = getGroupBoxById(strActiveBoxId)
- setOpacityForGroupBox(obj, 1.0)
- }
-
- clearSubBoxHighlighting();
- }
-
- function clearSubBoxHighlighting()
- {
- if( strActiveSubBoxId != "" )
- {
- var obj = getSubBoxById(strActiveSubBoxId);
- obj.style.backgroundColor = "transparent";
- };
- };
-
- function setOpacityForGroupBox(obj, val)
- {
- if (typeof(obj) == "object")
- {
- setOpacityForObjecs(obj, "rect", val);
- setOpacityForObjecs(obj, "roundrect", val);
- setOpacityForObjecs(obj, "shape", val);
- setOpacityForObjecs(obj, "oval", val);
- }
- }
-
- function setOpacityForObjecs(obj, name, val)
- {
- var rectObjs = obj.getElementsByTagName(name);
- var fillObjs;
- var objFill;
- var strName;
-
- for (i = 0; i < rectObjs.length; i++)
- {
- fillObjs = rectObjs(i).getElementsByTagName("fill");
- if (fillObjs.length > 0)
- {
- objFill = fillObjs(0);
- strName = rectObjs(i).getAttribute("name");
-
- if ( strName == "SelectTranspRect" || strName == "SelectRect" && getIEVersion() < 6.0 )
- objFill.setAttribute("on", val != 1.0);
-
- var objId = rectObjs(i).id;
- var bFound = false;
-
- if (objId != null)
- {
- var nLen = objId.length;
- var strToSearch = "_HitTestRect";
- if (nLen > strToSearch.length )
- {
- var s = objId.substr(nLen - strToSearch.length, nLen - 1);
- if (s == strToSearch)
- bFound = true;
- }
- }
- if (!bFound)
- objFill.setAttribute("opacity", val);
- }
- }
- }
-
- function onChartPageResized()
- {
- updateOverviewWindow()
- }
-
- function onWndResized()
- {
- var toolBar = parent.hcToolbar;
- if( toolBar == null ) return;
-
- if (toolBar.bFitToWindow)
- parent.hcMain.scrolling='no';
-
- if( typeof(toolBar) == "object" && typeof( toolBar.tryCenterPage ) != "undefined" &&
- typeof( toolBar.ZoomToFit ) != "undefined" )
- {
- if (parent.bAutoFitToWindow)
- toolBar.ZoomToFit();
- else
- toolBar.tryCenterPage();
- }
-
- updateOverviewWindow();
- }
-
- function onBeforePrint()
- {
- if( parent != self )
- return;
-
- CorrectObj( document.body, 1270 / document.body.scrollWidth );
-
- var arrows = document.all.SubChartArrow;
- if( arrows == null ) return;
-
- for( var i = 0; i < arrows.length; ++i )
- arrows[i].style.visibility = "hidden";
- }
-
- function CorrectObj( p_oObj, p_iK )
- {
- if( p_oObj.tagName == "line" )
- {
- p_oObj.from.x *= p_iK;
- p_oObj.from.y *= p_iK;
- p_oObj.to.x *= p_iK;
- p_oObj.to.y *= p_iK;
- }
- else
- {
- if( p_oObj.style )
- {
- p_oObj.style.pixelLeft *= p_iK;
- p_oObj.style.pixelTop *= p_iK;
- p_oObj.style.pixelWidth *= p_iK;
- p_oObj.style.pixelHeight *= p_iK;
-
- if( p_oObj.style.fontWeight )
- p_oObj.style.fontSize = parseInt(p_oObj.currentStyle.fontSize)*p_iK;
- }
-
- if( p_oObj.coordsize && p_oObj.tagName == "group")
- {
- p_oObj.coordsize.x *= p_iK;
- p_oObj.coordsize.y *= p_iK;
- }
- }
-
- for( var i = 0; i < p_oObj.childNodes.length; ++i )
- CorrectObj( p_oObj.childNodes[i], p_iK )
- }
-
- function onPageInit() //SPb AGal 15.10.2004
- {
- if( parent == self )
- {
- window.print();
- window.close();
-
- return;
- }
-
- var toolBar = parent.hcToolbar
-
- if (toolBar.visibility == "hidden")
- {
- toolBar.bFitToWindow = true;
- toolBar.SetAutoFitFlag();
- }
-
- toolBar.bZoomInitReady = toolBar.bFitToWindow ? false : true;
-
- onChartPageInit();
- }
-
- function getPersonsObj()
- {
- if( parent.hcPersons == null ) return null;
-
- var spanObjs = parent.hcPersons.document.body.children.tags("span")
- if(spanObjs.length == 0)
- return null
- var idxObj = null
- for(var j = 0; j < spanObjs.length; ++j)
- {
- if(spanObjs(j).id == "Index")
- {
- idxObj = spanObjs(j)
- break
- }
- }
- spanObjs = idxObj.children.tags("span")
- if(spanObjs.length == 0)
- return
- var personsObj = null
- for(var j = 0; j < spanObjs.length; ++j)
- {
- if(spanObjs(j).id == "Persons")
- {
- personsObj = spanObjs(j)
- break
- }
- }
- return personsObj
- }
-
- function getFieldsObj()
- {
- var spanObjs = parent.hcPersons.document.body.children.tags("span")
- if(spanObjs.length == 0)
- return null
- var idxObj = null
- for(var j = 0; j < spanObjs.length; ++j)
- {
- if(spanObjs(j).id == "Index")
- {
- idxObj = spanObjs(j)
- break
- }
- }
- if(idxObj == null) return null
- spanObjs = idxObj.children.tags("span")
- if(spanObjs.length == 0)
- return;
- var fieldsObj = null
- for(var j = 0; j < spanObjs.length; ++j)
- {
- if(spanObjs(j).id == "Fields")
- {
- fieldsObj = spanObjs(j)
- break
- }
- }
- return fieldsObj
- }
-
-
- function findPersonNode(id, parent)
- {
- if(parent == null)
- {
- parent = getPersonsObj()
- if(parent == null) return null
- }
- var spanObjs = parent.children.tags("span")
- if(spanObjs.length == 0)
- return null
-
- for(var j = 0; j < spanObjs.length; ++j)
- {
- if(spanObjs(j).id == id)
- return spanObjs(j)
- }
-
- for(var j = 0; j < spanObjs.length; ++j)
- {
- var spanObj = findPersonNode(id,spanObjs(j))
- if(spanObj != null) return spanObj
- }
- return null
- }
-
- function HS_PrepareHtml( )
- {
- if( !parent.hcPersons ) return;
- p_iID = event.srcElement.GroupId;
- p_StrID = event.srcElement.strId;
-
- var iFrame = window.frames.hcHTMLProfile;
- var html = iFrame.document.body.innerHTML;
- var oData = parent.hcPersons.document.all[ p_iID ];
- var FieldDefs = parent.hcMain.getFieldsObj();
- if( FieldDefs == null ) return;
-
- var objProf = document.all[ p_StrID ];
- if (objProf == null)
- return;
-
- for( var i = 0; i < FieldDefs.children.length; ++i )
- {
- var templateName = "\\[@" + FieldDefs.children[i].name + "@\\]";
- for( var fi = 0; fi < oData.children.length; ++fi )
- if( oData.children[fi].tagName == "PARAM" && oData.children[fi].id == FieldDefs.children[i].id )
- {
- groupValue = oData.children[fi];
- break;
- };
-
- html = html.replace( new RegExp( templateName, "g"), groupValue.name );
- }
-
- objProf.innerHTML = html;
-
- var oImagesCollection = objProf.getElementsByTagName("IMG");
- if( typeof(oImagesCollection) == 'undefined' || oImagesCollection == null )
- return;
-
- for( var i = 0; i < oImagesCollection.length; ++i )
- oImagesCollection[i].onerror = HS_ImageHider;
- }
-
- function HS_ImageHider()
- {
- event.srcElement.style.visibility = "hidden";
- };
-
- var cellArray = null
- function ShowHSProfile(profileId, bShow)
- {
- var strId = "prof"+profileId;
- var objProf = document.all(strId);
- if (objProf == null)
- return;
-
- var objGroup = GetGroupForObject(event.srcElement)
-
- if( objProf.profileType == "html")
- {
- if( bShow )
- {
- var iFrame = window.frames.hcHTMLProfile;
- if( iFrame == null )
- {
- var frm = document.createElement( "<iframe onload=\"HS_PrepareHtml()\" id=\"hcHTMLProfile\" name=\"hcHTMLProfile\" width=0 scrolling='no' border='0' frameborder='0' noresize topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'></iframe>")
- document.body.appendChild( frm );
- frm.src = objProf.profileURL;
- iFrame = window.frames.hcHTMLProfile;
- }
- else
- {
- iFrame.location.href = objProf.profileURL;
- }
-
- iFrame.frameElement.GroupId = objGroup.id;
- iFrame.frameElement.strId = strId;
- }
-
- var x = window.event.clientX + document.body.scrollLeft;
- var y = window.event.clientY + document.body.scrollTop;
- objProf.style.left = x;
- objProf.style.top = y;
- var strShowCmd = bShow ? "visible" : "hidden";
- objProf.style.visibility = strShowCmd;
- objProf.style.backgroundColor = "white";
-
- return;
- }
-
- var objPerson = findPersonNode(objGroup.id, null)
- if (objPerson == null)
- return;
-
- if (bShow)
- {
- var imgs = new Array()
- var imgSrcs = new Array()
-
- cellArray = new Array()
- var paramObjs = objPerson.getElementsByTagName("param")
- var rows = objProf.children[0].rows;
- var k = 0, n = 0;
-
- var cellright = null
-
- for (i = 0; i < rows.length; ++i)
- {
- var cells = rows[i].cells;
- var cell = cells[1];
- var merged = false;
- if (cell == null)
- {
- merged = true;
- cell = cells[0];
- }
- else if (cellright == null)
- cellright = cell
- for (j = 0; j < paramObjs.length; ++j)
- {
- var p = paramObjs(j)
- if (cell.id != null && cell.id == p.id)
- {
- if (p.img != null )
- {
- var img = cell.getElementsByTagName("img")[0]
- if (img != null && p.name && p.name != "")
- {
- imgs[n] = img
- if (merged)
- img.merged = true
- imgSrcs[n++] = p.name
- img.style.visibility = "";
- }
- else if( img )
- {
- img.style.visibility = "hidden";
- }
- }
- else
- {
- if (p.name == "")
- {
- cell.innerHTML = " "
- if (cell.style.textDecoration != "none")
- {
- cellArray[k++] = cell;
- cellArray[k++] = cell.style.textDecoration;
- cell.style.textDecoration = "none"
- }
- }
- else
- cell.innerText = p.name
- }
- break;
- }
- }
- }
-
- var w1 = objProf.children[0].pixelWidth
- var w2 = cellright != null ? cellright.pixelWidth : null
-
- for (i = 0; i < imgs.length; ++i)
- {
- var img = imgs[i]
- img.src = imgSrcs[i]
- if (img.merged != null)
- img.width = w1 - 2;
- else if (w2 != null)
- img.width = w2 - 2;
- }
- }
- var x = window.event.clientX + document.body.scrollLeft
- var y = window.event.clientY + document.body.scrollTop
- objProf.style.left = x
- objProf.style.top = y
- var strShowCmd = bShow ? "visible" : "hidden"
- objProf.style.visibility = strShowCmd;
-
- if (!bShow)
- {
- for (i = 0; i < cellArray.length; i +=2)
- {
- cellArray[i].style.textDecoration = cellArray[i+1]
- }
- }
- }
-